package com.chmingx.JavaBasic.lambda;

import java.util.function.LongSupplier;

public class FabonacciSupplier implements LongSupplier {
    private long x = 1;
    private long y = 1;
    private long count = 1;

    @Override
    public long getAsLong() {
        if (count == 1) {
            count++;
            return x;
        } else if (count == 2) {
            count++;
            return y;
        }
        count++;
        long z = x + y;
        x = y;
        y = z;
        return y;
    }
}
